package ar.uade.distribuidas.tpo.dba.dao;

import java.rmi.RemoteException;
import java.util.LinkedList;
import java.util.List;

import org.hibernate.Session;

import ar.uade.distribuidas.tpo.dba.dominio.Proveedor;
import ar.uade.distribuidas.tpo.dba.hbt.HibernateDAO;


public class ProveedorDAO extends HibernateDAO{
	public static ProveedorDAO instance;

	protected ProveedorDAO(){
	}

	public static ProveedorDAO getInstance() {
		if (instance == null){
			instance = new ProveedorDAO();
		}
		return instance;
	}
	
	public Proveedor getProveedor(Long cuil)throws RemoteException{
		Proveedor p = (Proveedor) this.getSession().createQuery("from Proveedor where cuil = :cuil").setParameter("cuil", cuil).list().get(0);		
		return p;
	}
	
	@SuppressWarnings("unchecked")
	public List<Proveedor> getAllProveedores(){
		List<Proveedor> res = new LinkedList<Proveedor>();
	           
		res =  this.getSession().createQuery("from Proveedor").list();
		return res;
	}
}
